package org.example.netty.groupchat;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;

import java.net.SocketAddress;

public class GroupChatServerOutBoundHandler extends ChannelOutboundHandlerAdapter {

    /**
     * 1.蒋婷绑定：完成底层Java IO通道的IP地址绑定
     *
     * @param channelHandlerContext
     * @param socketAddress
     * @param channelPromise
     * @throws Exception
     */
    @Override
    public void bind(ChannelHandlerContext channelHandlerContext, SocketAddress socketAddress, ChannelPromise channelPromise) throws Exception {

    }

    /**
     * 2.连接服务器，如果使用TCP客户端，这个方法用于客户端
     *
     * @param channelHandlerContext
     * @param socketAddress
     * @param socketAddress1
     * @param channelPromise
     * @throws Exception
     */
    @Override
    public void connect(ChannelHandlerContext channelHandlerContext, SocketAddress socketAddress, SocketAddress socketAddress1, ChannelPromise channelPromise) throws Exception {

    }

    /**
     * 6.断开服务器连接，此方法主要用于TCP客户顿
     *
     * @param channelHandlerContext
     * @param channelPromise
     * @throws Exception
     */
    @Override
    public void disconnect(ChannelHandlerContext channelHandlerContext, ChannelPromise channelPromise) throws Exception {

    }

    /**
     * 7.主动关闭通道
     *
     * @param channelHandlerContext
     * @param channelPromise
     * @throws Exception
     */
    @Override
    public void close(ChannelHandlerContext channelHandlerContext, ChannelPromise channelPromise) throws Exception {

    }

    @Override
    public void deregister(ChannelHandlerContext channelHandlerContext, ChannelPromise channelPromise) throws Exception {

    }

    /**
     * 5.从底层读取数据，完成从Netty通道从Java IO通道的数据读取
     *
     * @param channelHandlerContext
     * @throws Exception
     */
    @Override
    public void read(ChannelHandlerContext channelHandlerContext) throws Exception {

    }

    /**
     * 3.写数据到底层：完成Netty通道相地层Java IO通道的数据写入操作。此方法仅仅是触发一下操作，并不是实际完成。
     *
     * @param channelHandlerContext
     * @param o
     * @param channelPromise
     * @throws Exception
     */
    @Override
    public void write(ChannelHandlerContext channelHandlerContext, Object o, ChannelPromise channelPromise) throws Exception {

    }

    @Override
    public void flush(ChannelHandlerContext channelHandlerContext) throws Exception {

    }

    @Override
    public void handlerAdded(ChannelHandlerContext channelHandlerContext) throws Exception {

    }

    @Override
    public void handlerRemoved(ChannelHandlerContext channelHandlerContext) throws Exception {

    }

    @Override
    public void exceptionCaught(ChannelHandlerContext channelHandlerContext, Throwable throwable) throws Exception {

    }
}
